home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / bsrc_p1.arc / FTSC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-30  |  24.3 KB  |  831 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software <no-Inc>                   */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          No-Cost<no-tm> Software.                       */
  7. /*        \ 1011 /                                                          */
  8. /*         ------            KopyRong (K) 1987.  ALL RIGHTS REVERSED.       */
  9. /*                                                                          */
  10. /*                                                                          */
  11. /*                 This module was written by Bob Hartman                   */
  12. /*                                                                          */
  13. /*                                                                          */
  14. /*                 BinkleyTerm FTSC Mail Session Routines                   */
  15. /*                                                                          */
  16. /*                                                                          */
  17. /*   This  software  package is being distributed WITH FULL SOURCE CODE     */
  18. /*   with the  following  conditions:    1)  If  anything awful happens     */
  19. /*   because  you  use    it   (or  don't  use  it),  you  accept  full     */
  20. /*   responsibility;  2) you  don't start making tons of voice calls to     */
  21. /*   the authors to complain or  make  suggestions  about enhancements,     */
  22. /*   useful or otherwise;  3) you  do not reuse this code in commercial     */
  23. /*   products without specific permission to do so  from  the  authors;     */
  24. /*   4) If you find any problems you send  fixes  to  the  authors  for     */
  25. /*   inclusion  in  updates;    5) You find some way  to  express  your     */
  26. /*   appreciation  for  this  method of distribution, either by writing     */
  27. /*   code or  application  notes,  or  just sending along a "Thank You"     */
  28. /*   message.                                                               */
  29. /*                                                                          */
  30. /*   There is  copyrighted  code  in  this product.  We either wrote it     */
  31. /*   ourselves or got  permission  to use it.  Please don't force us to     */
  32. /*   pay a lawyer --  have some respect for our motives and don't abuse     */
  33. /*   this "license".                                                        */
  34. /*                                                                          */
  35. /*                                                                          */
  36. /*--------------------------------------------------------------------------*/
  37.  
  38. #include <signal.h>
  39. #include <ctype.h>
  40. #include <conio.h>
  41. #include <time.h>
  42.  
  43. #define WAZOO_SECTION
  44. #define MATRIX_SECTION
  45.  
  46. #define isBITBRAIN 0x1b
  47.  
  48. #include "zmodem.h"
  49. #include "com.h"
  50.  
  51. #define rb_plus "r+b"
  52.  
  53. extern char *BUNDLE_msg;
  54. extern char *FIND_msg;
  55. extern char *WRITE_msg;
  56. extern char *FLAGGING_msg;
  57. extern char *TRUNC_msg;
  58.  
  59. extern char *ext_flags;       /* Change to whatever, and */
  60. extern int net_problems;        /* This should be external */
  61. extern int un_attended;
  62. extern int fullscreen;
  63. extern char no_pickup;
  64. extern char no_requests;
  65. extern int remote_net, remote_node;
  66. extern int called_net, called_node;
  67. extern char *remote_password;
  68. extern int sent_mail;
  69. extern int got_bundle, got_arcmail, got_mail;
  70. extern int caller;
  71. char no_requests = 0;
  72. int n_requests = 100;
  73. #define NUM_FLAGS 4                /* bump this, to add flags */
  74.  
  75. FTSC_Whack_CR()
  76. {
  77.    long t1,t2,timerset();
  78.    char i, j, k, l, m;
  79.    char buf[80];
  80.  
  81. /*   CLEAR_INBOUND(); */
  82.    t1 = timerset(3000);                       /* set 30 second timeout */
  83.    j = CR;
  84.    if (un_attended && fullscreen)
  85.       {
  86.       gotoxy (0, 15);
  87.       clear_bottom();
  88.       }
  89.    else
  90.       {
  91.       set_xy("");
  92.       }
  93.    strcpy (buf, "Called: ");
  94.    l = strlen (buf);
  95.    m = 0;
  96.    while (!timeup(t1) && CARRIER)            /* till then or CD lost  */
  97.        {
  98. /*      message( "Knock. Knock. Anybody home?    " );*/
  99.  
  100.       /* Send either the CR or SPACE */
  101.       SENDBYTE (j);
  102.  
  103.       /* Now switch to either CR or SPACE based on last output */
  104.       j = 45 - j;
  105.  
  106.       /* Now read what we get back to see if we get anything useful */
  107.       while (((i = TIMED_READ(0)) != EOF) && (!timeup(t1)) && CARRIER)
  108.          {
  109.          if (i == CR)
  110.             {
  111.             if (m)
  112.                {
  113.                if (un_attended && fullscreen)
  114.                   {
  115.                   gotoxy (0,16);
  116.                   }
  117.                scr_printf ( buf );
  118. /*               scr_printf ( "'" );
  119.                set_xy( "Yah Hoo! There's somebody home." ); */
  120.                /* We got what we wanted */
  121.                /* Now try to stop output on an Opus */
  122.                SENDBYTE(' ');
  123.                return (0);
  124.                }
  125.             }
  126.          else if (i >= ' ')
  127.             {
  128.             buf[l++] = i;
  129.             buf[l] = '\0';
  130.             if (l > 77)
  131.                l = 77;
  132.             m = 1;
  133.             }
  134.          }
  135.  
  136.       /* Delay for a second */
  137.       t2 = timerset (100);
  138.       while (!timeup (t2))
  139.          time_release();
  140.        }
  141.  
  142.    status_line ("*Nobody answered the door");
  143.    return (-1);
  144. }
  145.  
  146. FTSC_sender (wz)
  147. int wz;
  148. {
  149.    int j;
  150.    long t1, timerset();
  151.  
  152.    if (!wz)
  153.       status_line("*Initiating LoTek Matrix Session");
  154.  
  155.    FTSC_sendmail ();
  156.    t1 = timerset (1000);
  157.  
  158.    /* See what the receiver would like us to do */
  159.    while ((!timeup (t1)) && CARRIER)
  160.       {
  161.       if ((j = PEEKBYTE()) >= 0)
  162.          {
  163.          switch (j)
  164.             {
  165.             case TSYNC:
  166.                CLEAR_INBOUND();
  167.                if (FTSC_recvmail())
  168.                   goto get_out;
  169.                t1 = timerset (1000);
  170.                break;
  171.  
  172.             case SYN:
  173.                CLEAR_INBOUND();
  174.                SEA_recvreq();
  175.                t1 = timerset (1000);
  176.                break;
  177.  
  178.             case ENQ:
  179.                CLEAR_INBOUND();
  180.                SEA_sendreq();
  181.                goto get_out;
  182.                break;
  183.  
  184.             case NAK:
  185.             case 'C':
  186.                TIMED_READ(0);
  187.                TIMED_READ(1);
  188.                TIMED_READ(1);
  189.                SENDBYTE(EOT);
  190.                t1 = timerset (1000);
  191.                break;
  192.  
  193.             default:
  194.                TIMED_READ(0);
  195.                SENDBYTE(EOT);
  196.                break;
  197.             }
  198.          }
  199.       else
  200.          {
  201.          time_release();
  202.          }
  203.       }
  204.  
  205.    if (!CARRIER)
  206.       {
  207.       status_line("!Other end hung up on us <humph>.");
  208.       CLEAR_INBOUND();
  209.       return FALSE;
  210.       }
  211.  
  212.    if (timeup(t1))
  213.       {
  214.       FTSC_recvmail();
  215.       status_line ("!Tired of waiting for other end.");
  216.       }
  217.  
  218. get_out:
  219.    t1 = timerset (100);
  220.    while (!timeup (t1))
  221.       time_release();
  222.    if (!wz)
  223.       status_line ("*End of LoTek Matrix Session");
  224. }
  225.  
  226. FTSC_receiver (wz)
  227. int wz;
  228. {
  229.    char fname[64];
  230.    int havemail, done;
  231.    unsigned char i, j;
  232.    long t1, t2, timerset();
  233.    struct FILEINFO dt1;
  234.    struct stat buf;
  235.  
  236.    if (!wz)
  237.       status_line("*Answering LoTek Matrix Session");
  238.  
  239.    CLEAR_INBOUND();
  240.  
  241.    /* Save the state of pickup for now */
  242.    done = no_pickup;
  243.    no_pickup = 0;
  244.    if (FTSC_recvmail ())
  245.       {
  246.       /* Restore the state of pickup */
  247.       no_pickup = done;
  248.       if (!wz)
  249.          status_line ("*End of LoTek Matrix Session");
  250.       return (1);
  251.       }
  252.  
  253.    /* Restore the state of pickup */
  254.    no_pickup = done;
  255.  
  256.    remote_net = called_net;
  257.    remote_node = called_node;
  258.  
  259.    /* Now see if we should send anything back to him */
  260.    sprintf( fname, "%s%04x%04x.?UT", ctl.hold_area,remote_net,remote_node);
  261.    havemail = dfind (&dt1, fname, 0);
  262.  
  263.    if (havemail)
  264.       {
  265.       sprintf( fname, "%s%04x%04x.?LO", ctl.hold_area,remote_net,remote_node);
  266.       havemail = dfind (&dt1, fname, 0);
  267.       }
  268.  
  269.    if (havemail)
  270.       {
  271.       sprintf( fname, "%s%04x%04x.REQ", ctl.filepath,ctl.alias[0].net,ctl.alias[0].node);
  272.       havemail = dfind (&dt1, fname, 0);
  273.       }
  274.  
  275.    if (havemail)
  276.       {
  277.       status_line ("*No mail waiting for %d/%d", remote_net, remote_node);
  278.       }
  279.    else
  280.       {
  281.       status_line ("*Giving mail to %d/%d", remote_net, remote_node);
  282.       /* Send the TSYNC's until we get a C or NAK back */
  283.       t1 = timerset(3000);                /* set 30 second timeout */
  284.       j = 0;
  285.       done = 0;
  286.       while (!timeup(t1) && CARRIER && !done)        /* till then or CD lost  */
  287.           {
  288.          SENDBYTE(TSYNC);
  289.  
  290.          t2 = timerset (300);
  291.          while (CARRIER && (!timeup(t2)) && !done)
  292.             {
  293.             i = TIMED_READ (0);
  294.  
  295.             switch (i)
  296.                {
  297.                case 'C':
  298.                case 0x00:
  299.                case 0x01:
  300.                   if (j == 'C')
  301.                      {
  302.                      done = 1;
  303.                      FTSC_sendmail ();
  304.                      }
  305.                   break;
  306.  
  307.                case 0xfe:
  308.                   if (j == 0x01)
  309.                      {
  310.                      done = 1;
  311.                      FTSC_sendmail ();
  312.                      }
  313.                   break;
  314.  
  315.                case 0xff:
  316.                   if (j == 0x00)
  317.                      {
  318.                      done = 1;
  319.                      FTSC_sendmail ();
  320.                      }
  321.                   else
  322.                      {
  323.                      time_release();
  324.                      }
  325.                   break;
  326.  
  327.                case NAK:
  328.                   if (j == NAK)
  329.                      {
  330.                      done = 1;
  331.                      FTSC_sendmail ();
  332.                      }
  333.                   break;
  334.                }
  335.             if (i != -1)
  336.                j = i;
  337.             }
  338.           }
  339.       }
  340.  
  341.    /* Now see if we want to request anything */
  342.    sprintf( fname, "%s%04x%04x.REQ", ctl.hold_area,remote_net,remote_node);
  343.    if (!stat(fname,&buf))
  344.       {
  345.       /* Send the SYN character and wait for an ENQ or CAN */
  346.       t1 = timerset(3000);                /* set 30 second timeout */
  347.       done = 0;
  348.       while (!timeup(t1) && CARRIER && !done)        /* till then or CD lost  */
  349.           {
  350.          SENDBYTE(SYN);
  351.  
  352.          t2 = timerset (300);
  353.          while (CARRIER && (!timeup(t2)) && !done)
  354.             {
  355.             i = TIMED_READ (0);
  356.  
  357.             switch (i)
  358.                {
  359.                case ENQ:
  360.                   SEA_sendreq ();
  361.  
  362.                case CAN:
  363.                   done = 1;
  364.                   break;
  365.  
  366.                case 'C':
  367.                case NAK:
  368.                   SENDBYTE (EOT);
  369.                   break;
  370.  
  371.                default:
  372.                   time_release();
  373.                }
  374.             }
  375.           }
  376.       }
  377.  
  378.    /* Finally, can he request anything from us */
  379.    if (!no_requests)
  380.       SEA_recvreq ();
  381.  
  382.    if (!wz)
  383.       status_line ("*End of LoTek Matrix Session");
  384. }
  385.  
  386. FTSC_sendmail ()
  387. {
  388.    FILE       *fp;
  389.    char        fname[80];
  390.    char        s[80];
  391.    char       *sptr;
  392.    char       *password;
  393.    char        p;
  394.    int         c;
  395.    int         i,j;
  396.    int         fsent;
  397.    struct stat buf;
  398.    struct _pkthdr *tmppkt;
  399.    long        t1, time(), timerset();
  400.    struct      tm *tm1, *localtime();
  401.  
  402.    long        current, last_start;
  403.  
  404.    sptr        = s;
  405.    /*--------------------------------------------------------------------*/
  406.    /* Send all waiting ?UT files (mail bundles)                          */
  407.    /*--------------------------------------------------------------------*/
  408.    *ext_flags  = 'O';
  409.    for(c=0; c<NUM_FLAGS; c++)
  410.       begin
  411.          if (caller && (ext_flags[c] == 'H'))
  412.             continue;
  413.  
  414.          sprintf( fname,
  415.                   "%s%04x%04x.%cUT",
  416.                   ctl.hold_area,called_net,called_node,ext_flags[c]);
  417.          errno = 0;
  418.  
  419.          if (!stat(fname,&buf))
  420.             break;
  421.       end /* for */
  422.  
  423.    /*--- Build a dummy PKT file name */
  424.    invent_pkt_name(s);
  425.  
  426.    status_line(" Sending bundle to %d/%d", called_net, called_node);
  427.  
  428.    if (c == NUM_FLAGS)
  429.       {
  430.       sprintf( fname,
  431.                "%s%04x%04x.OUT",
  432.                ctl.hold_area,called_net,called_node);
  433.       errno = 0;
  434.       fp = fopen (fname, "wb");
  435.       if (got_error(OPEN_msg,fname))
  436.          {
  437.          return (1);
  438.          }
  439.       errno = 0;
  440.       t1 = time (NULL);
  441.       tm1 = localtime (&t1);
  442.  
  443.       tmppkt = (struct _pkthdr *) calloc (sizeof (struct _pkthdr), 1);
  444.       if (tmppkt == NULL)
  445.          {
  446.          status_line ("!Mem err in sending");
  447.          fclose (fp);
  448.          return (1);
  449.          }
  450.       tmppkt->orig_node = ctl.alias[0].node;
  451.       tmppkt->dest_node = called_node;
  452.       tmppkt->year = tm1->tm_year;
  453.       tmppkt->month = tm1->tm_mon;
  454.       tmppkt->day = tm1->tm_mday;
  455.       tmppkt->hour = tm1->tm_hour;
  456.       tmppkt->minute = tm1->tm_min;
  457.       tmppkt->second = tm1->tm_sec;
  458.       tmppkt->rate = 0;
  459.       tmppkt->ver = PKTVER;
  460.       tmppkt->orig_net = ctl.alias[0].net;
  461.       tmppkt->dest_net = called_net;
  462.       tmppkt->product = isBITBRAIN;
  463.       if (n_getpassword(called_net,called_node))
  464.          {
  465.          if (remote_password != NULL)
  466.             {
  467.             strncpy (tmppkt->pwd_kludge, remote_password, 6);
  468.             strupr (tmppkt->pwd_kludge);
  469.             }
  470.          }
  471.       fwrite ((char *) tmppkt, sizeof (struct _pkthdr), 1, fp);
  472.       free (tmppkt);
  473.       if (got_error(WRITE_msg, fname))
  474.          {
  475.          fclose (fp);
  476.          return (1);
  477.          }
  478.       fwrite ("\0\0", 2, 1, fp);
  479.       fclose (fp);
  480.       }
  481.    else
  482.       {
  483.       if (n_getpassword(called_net,called_node))
  484.          {
  485.          if (remote_password != NULL)
  486.             {
  487.             errno = 0;
  488.             fp = fopen (fname, rb_plus);
  489.             if (got_error(OPEN_msg,fname))
  490.                {
  491.                return (1);
  492.                }
  493.             tmppkt = (struct _pkthdr *) calloc (sizeof (struct _pkthdr), 1);
  494.             if (tmppkt == NULL)
  495.                {
  496.                status_line ("!Mem err in sending");
  497.                return (1);
  498.                }
  499.             errno = 0;
  500.             fread (tmppkt, 1, sizeof (struct _pkthdr), fp);
  501.             if (got_error(READ_msg, fname))
  502.                {
  503.                free (tmppkt);
  504.                fclose (fp);
  505.                return (1);
  506.                }
  507.             strncpy (tmppkt->pwd_kludge, remote_password, 6);
  508.             strupr (tmppkt->pwd_kludge);
  509.  
  510.             errno = 0;
  511.             fseek (fp, 0L, SEEK_SET);
  512.             fwrite (tmppkt, 1, sizeof (struct _pkthdr), fp);
  513.             fclose (fp);
  514.             free (tmppkt);
  515.             }
  516.          }
  517.       }
  518.  
  519.    net_problems = send_file (fname, 'S');
  520.    if ((net_problems == TSYNC) || (net_problems == 0))
  521.       {
  522.       if (c == NUM_FLAGS)
  523.          unlink (fname);
  524.       return (net_problems);
  525.       }
  526.  
  527.    /* Delete the sent bundle */
  528.    unlink (fname);
  529.  
  530.  
  531.       /*--------------------------------------------------------------------*/
  532.       /* Send files listed in ?LO files (attached files)                    */
  533.       /*--------------------------------------------------------------------*/
  534.       *ext_flags  = 'F';
  535.       status_line (" Outbound file attaches");
  536.       for(c=0; c<NUM_FLAGS+1; c++)
  537.          begin
  538.             if (caller && (ext_flags[c] == 'H'))
  539.                continue;
  540.  
  541.             if (c < NUM_FLAGS)
  542.                {
  543.                sprintf( fname, "%s%04x%04x.%cLO",
  544.                      ctl.hold_area,called_net,called_node,ext_flags[c]);
  545.                }
  546.             else
  547.                {
  548.                sprintf( fname, "%s%04x%04x.REQ",
  549.                      ctl.filepath,ctl.alias[0].net, ctl.alias[0].node);
  550.                }
  551.             errno = 0;
  552.  
  553.             if (!stat(fname,&buf))
  554.                begin
  555.  
  556.                   errno = 0;
  557.                   fp = fopen( fname, rb_plus );
  558.                   if (got_error(OPEN_msg,fname))
  559.                      begin
  560.                         continue;
  561.                      end
  562.  
  563.                   current  = 0L;
  564.                   while(!feof(fp))
  565.                      begin
  566.                         s[0]        = 0;
  567.                         last_start  = current;
  568.                         fgets(s,79,fp);
  569.                         if (got_error(READ_msg,fname)) s[0] = 0;
  570.  
  571.                         sptr        = s;
  572.                         password    = NULL;
  573.  
  574.                         for(i=0; sptr[i]; i++)
  575.                            if (sptr[i]=='!') password = sptr+i+1;
  576.  
  577.                         if (password)
  578.                            begin
  579.                               password = sptr+i+1;
  580.                               for(i=0; password[i]; i++)
  581.                                  if (password[i]<=' ') password[i]=0;
  582.                               fancy_str(password);
  583.                               if (strcmp(password,remote_password))
  584.                                  begin
  585.                                     status_line("!RemotePwdErr %s %s",password,remote_password);
  586.                                     continue;
  587.                                  end
  588.                            end
  589.  
  590.                         for(i=0; sptr[i]; i++)
  591.                            if (sptr[i]<=' ') sptr[i]=0;
  592.  
  593.                         current     = ftell(fp);
  594.  
  595.                         if (sptr[0]=='#')
  596.                            begin
  597.                                sptr++;
  598.                               i     = TRUNC_AFTER;
  599.                            end
  600.                         else  i     = NOTHING_AFTER;
  601.  
  602.                         if (!sptr[0])
  603.                            begin
  604.                               continue;
  605.                            end
  606.  
  607.  
  608.                         if (sptr[0] != '~')
  609.                            begin
  610.  
  611.                               if (stat(sptr,&buf)) /* file exist? */
  612.                                  begin
  613.                                     got_error(FIND_msg,sptr);
  614.                                     continue;
  615.                                  end
  616.                               else if (!buf.st_size)
  617.                                  begin
  618.                                     continue; /* 0 length? */
  619.                                  end
  620.  
  621.                               j = xfermdm7 (sptr);
  622.                               p = 'T';
  623.                               if (j == 0)
  624.                                  {
  625.                                  net_problems = 1;
  626.                                  return FALSE;
  627.                                  }
  628.                               else if (j == 2)
  629.                                  p = 'F';
  630.  
  631.                               if (!send_file (sptr, p)) 
  632.                                  begin
  633.                                     fclose(fp);
  634.                                     net_problems   = 1;
  635.                                     return FALSE;
  636.                                  end
  637.  
  638.                               /*--------------------------------------------*/
  639.                               /* File was sent.  Flag file name             */
  640.                               /*--------------------------------------------*/
  641.  
  642.                               fseek( fp, last_start, SEEK_SET );
  643.                               putc('~',fp); /* flag it */
  644.                               fflush (fp);
  645.                               rewind(fp); /* clear any eof flags */
  646.                               fseek( fp, current, SEEK_SET );
  647.                               errno = 0;
  648.  
  649.                               if (i == TRUNC_AFTER)
  650.                                  {
  651.                                  CLEAR_IOERR();
  652.                                  i = open(sptr,O_TRUNC,S_IWRITE);
  653.                                  got_error( TRUNC_msg, sptr );
  654.                                  status_line(FLAGGING_msg,sptr);
  655.                                  close(i);
  656.                                  }
  657.  
  658.                            end
  659.  
  660.                      end /* while */
  661.  
  662.                   errno = 0;
  663.                   fclose(fp);
  664.                   got_error(CLOSE_msg,fname);
  665.                   unlink(fname);
  666.                   errno = 0;
  667.  
  668.                end /* !stat */
  669.  
  670.          end /* for */
  671.    /* Now close out the file attaches */
  672.    sent_mail = 1;
  673.    *sptr = 0;
  674.    status_line (" End of outbound file attaches");
  675.    t1 = timerset (100);
  676.    while (CARRIER && !timeup(t1))
  677.       {
  678.       j = TIMED_READ(0);
  679.       if ((j == 'C') || (j == NAK))
  680.          {
  681.          SENDBYTE (EOT);
  682.          t1 = timerset (100);
  683.          }
  684.       else
  685.          {
  686.          time_release();
  687.          }
  688.       }
  689. }
  690.  
  691. FTSC_recvmail ()
  692. {
  693.    char fname[80];
  694.    char fname1[80];
  695.    struct _pkthdr tmppkt;
  696.    FILE *fp;
  697.    char *s;
  698.    char done;
  699.    char i;
  700.    int j;
  701.    extern char *receive_file();
  702.  
  703.    status_line ("*Receiving inbound mail");
  704.  
  705.    if (!CARRIER)
  706.       {
  707.       status_line("!Other end hung up on us <humph>.");
  708.       CLEAR_INBOUND();
  709.       return (1);
  710.       }
  711.  
  712.    /* If we don't want to pickup stuff */
  713.    if (no_pickup)
  714.       {
  715.       status_line ("*Pickup is turned off - refusing mail.");
  716.       SENDBYTE(CAN);
  717.       }
  718.    else
  719.       {
  720.       status_line (" Inbound bundle");
  721.       /* Invent a dummy name for the packet */
  722.       invent_pkt_name (fname);
  723.  
  724.       /* Receive the bundle with special netmail protocol */
  725.       CLEAR_INBOUND();
  726.       SENDBYTE ('C');
  727.       SENDBYTE (0x01);
  728.       SENDBYTE (0xfe);
  729.       if ((s = receive_file (ctl.filepath, fname, 'B')) != NULL)
  730.          {
  731.          got_bundle = 1;
  732.          }
  733.  
  734.       /* Check the password if there is one */
  735.       if (n_getpassword(remote_net,remote_node))
  736.          {
  737.          if (remote_password != NULL)
  738.             {
  739.             got_bundle = 0;
  740.             errno = 0;
  741.             sprintf (fname, "%s%s", ctl.filepath, s);
  742.             fp = fopen (fname, "r");
  743.             if (got_error(OPEN_msg,fname))
  744.                {
  745.                status_line ("!Password Error assumed");
  746.                return (1);
  747.                }
  748.             errno = 0;
  749.             fread (&tmppkt, 1, sizeof (struct _pkthdr), fp);
  750.             if (got_error(OPEN_msg,fname))
  751.                {
  752.                status_line ("!Password Error assumed");
  753.                fclose (fp);
  754.                return (1);
  755.                }
  756.             fclose (fp);
  757.             remote_password[7] = '\0';
  758.             tmppkt.pwd_kludge[7] = '\0';
  759.             if (stricmp (remote_password, tmppkt.pwd_kludge))
  760.                {
  761.                status_line ("!Password Error: expected '%s' got '%s'",
  762.                   remote_password, tmppkt.pwd_kludge);
  763.                strcpy (fname1, fname);
  764.                j = strlen (fname) - 3;
  765.                strcpy (&(fname[j]), "Bad");
  766.                if (rename (fname1, fname))
  767.                   {
  768.                   status_line ("!Packet '%s' cannot be renamed", fname1);
  769.                   }
  770.                else
  771.                   {
  772.                   status_line ("!Packet renamed to '%s'", fname);
  773.                   }
  774.                return (1);
  775.                }
  776.             }
  777.          got_bundle = 1;
  778.          }
  779.       called_net = remote_net;
  780.       called_node = remote_node;
  781.       got_mail = got_bundle;
  782.  
  783.       done = 0;
  784.       /* Now receive the files if possible */
  785.       status_line (" Inbound file attaches");
  786.       do
  787.          {
  788.          if ((i = try_sealink ()) == 0)
  789.             {
  790.             if (!recvmdm7 (fname))
  791.                {
  792.                done = 1;
  793.                }
  794.             else
  795.                {
  796.                if (!receive_file (ctl.filepath, NULL, 'T'))
  797.                   {
  798.                   if (locate_y>1) gotoxy(0,locate_y-1);
  799.                   done = 1;
  800.                   }
  801.                else
  802.                   {
  803.                   got_mail = 1;
  804.                   }
  805.                }
  806.             }
  807.          else if (i == 1)
  808.             {
  809.             if (!receive_file (ctl.filepath, NULL, 'F'))
  810.                {
  811.                if (locate_y>1) gotoxy(0,locate_y-1);
  812.                done = 1;
  813.                }
  814.             else
  815.                {
  816.                got_mail = 1;
  817.                }
  818.             }
  819.          else
  820.             {
  821.             done = 1;
  822.             }
  823.          } while (!done && CARRIER);
  824.       }
  825.  
  826.    status_line (" End of inbound file attaches");
  827.    CLEAR_INBOUND();
  828.    return (0);
  829. }
  830.  
  831.